package com.logica.hackthon;

import java.util.Properties;

import com.flca.DefaultFlcaStartupImpl;
import com.flca.frw.dao.DatabaseProperties;
import com.flca.frw.dao.IConnectionPoolMgr;
import com.flca.frw.log.ILog;
import com.flca.frw.log.LogHelper;
import com.flca.frw.util.IConfigurationHelper;
import com.google.inject.Inject;

public class HackThonFlcaStartup extends DefaultFlcaStartupImpl
{
	@Inject private IConfigurationHelper configHelper;
	@Inject private IConnectionPoolMgr connPoolMgr; 

	private static ILog logger = LogHelper.getLogger(HackThonFlcaStartup.class);

	@Override
	public String getDatabasePropertiesKey()
	{
		return "dbs.properties.default"; 
	}

	@Override
	public void initialize() 
	{
		String key = "appeng-hackthon-dbs.properties" ;//configHelper.getProperty(getDatabasePropertiesKey());
		logger.info("HackThonFlcaStartup.initialize with " + key);
		Properties properties = configHelper.getProperties(key);
		DatabaseProperties dbprops = new DatabaseProperties(properties);
		connPoolMgr.setupDefaultPersistenceMgr(dbprops);
		
		HackThonContext.INSTANCE.setStarter(this);
		logger.info("HackThonFlcaStartup.initialize succesfully finished");
	}
	
}
